// sku模块接口管理
import request from '@/utils/request'
import type { Response, PageInstanceVO } from '@/api/type'
import type { SkuList, SkuParam, SkuVO } from '@/api/product/sku/type'

const API = {
  UPDATE_SKU: '/admin/product/updateSku',// 修改sku
  SKU_LIST: '/admin/product/sku',// 查询sku列表
  DELETE_SKU: '/admin/product/sku/deleteSku',// 根据skuId删除sku
  CANCEL_SKU: '/admin/product/sku/cancelSku',// 取消上架
  ONLINE_SKU: '/admin/product/sku/onlineSku',// 上架sku
  QUERY_SKU_INFO: '/admin/product/sku/skuInfo',// 查询sku详情
  DELETE_SKU_INFO: '/admin/product/sku/deleteSkuInfo',// 删除sku详情
}

// 查询sku列表
export const reqSkuList = async (page: number, limit: number) => request.get<any, Response<PageInstanceVO<SkuVO>>>(
  `${API.SKU_LIST}/${page}/${limit}`
)

// 编辑sku
export const reqUpdateSku = async (data: SkuParam) => request.post<any, Response<void>>(API.UPDATE_SKU, data)

// 删除sku
export const reqRemoveSkuById = async (skuId: number) => request.delete<any, Response<void>>(`${API.DELETE_SKU}/${skuId}`)
// 取消上架
export const reqCancelSale = async (skuId: number) => request.get<any, Response<void>>(`${API.CANCEL_SKU}/${skuId}`)
// 上架sku
export const reqOnSale = async (skuId: number) => request.get<any, Response<void>>(`${API.ONLINE_SKU}/${skuId}`)

// 查询sku详情
export const reqSkuInfo = async (skuId: number) => request.get<any, Response<SkuVO>>(`${API.QUERY_SKU_INFO}/${skuId}`)
// 删除sku详情
export const reqRemoveSkuInfoById = async (skuId: number) => request.delete<any, Response<void>>(`${API.DELETE_SKU_INFO}/${skuId}`)